package com.kb.service.impl.common;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.kb.domain.Bom;
import com.kb.domain.BomRfq;
import com.kb.domain.BomRfqDetail;
import com.kb.domain.RepurchaseOrder;
import com.kb.mapper.sqlServer.CommonMapper;
import com.kb.service.common.CommonService;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

@DS("KBOM_SmartQuote")
@Service
public class CommonServiceImpl implements CommonService {
    @Resource
    CommonMapper CommonMapper;

    @Override
    public List<RepurchaseOrder> getRepurchaseOrder(String Part_No) {
        return CommonMapper.getRepurchaseOrder(Part_No);
    }

    @Override
    public List<BomRfqDetail> getBomDetail(String Rfq_No) {
        List<BomRfqDetail> bomDetail = CommonMapper.getBomDetail(Rfq_No);
        return bomDetail;
    }

    @Override
    public String getBomFile(String rfqNo) {
        String fileName = CommonMapper.getBomFile(rfqNo);
        return fileName;
    }

    @DS("KBOM_SmartQuote_Test")
    @Override
    public Bom getBomContent(String rfqNo) {
        Bom bom = new Bom();
        BomRfq bomRfq = CommonMapper.getBom(rfqNo);
        List<BomRfqDetail> bomContent = CommonMapper.getBomContent(rfqNo);
        if (bomContent != null){
            bom.setRfqDetile(bomContent);
            bom.setBomRfq(bomRfq);
        }
        return bom;
    }
}
